<!DOCTYPE html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><script type="text/javascript">
function toggle_toc() {
    var toc=document.getElementById('table-of-contents');
    var btn=document.getElementById('btn-text');
    toc.style.display=(toc.style.display=='none')?'block':'none';
    btn.innerHTML=(toc.style.display=='none')?'&#x25BC;':'&#x25B2;';
}
function toggle_source(name) {
    var showsource=document.getElementById('showsource-' + name);
    var btn=document.getElementById('btn-text-'+ name);
    showsource.style.display=(showsource.style.display=='none')?'block':'none';
    btn.innerHTML=(showsource.style.display=='none')?'&#x25BC;':'&#x25B2;';
}
</script></head><style>.markdown-body hr:after,.markdown-body hr:before{content: "";display: table;}.markdown-body .anchor:focus,.markdown-body a:active,.markdown-body a:hover{outline: 0;}@font-face{font-family: octicons-anchor;src: url(data:font/woff;charset=utf-8;base64,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) format('woff');}.readme{border: 1px solid #ddd;border-radius: 3px;display: table;margin: 20px auto;padding: 30px;width: 790px;}.markdown-body ol,.markdown-body td,.markdown-body th,.markdown-body ul{padding: 0;}.markdown-body{color: #333;font-family: "Helvetica Neue",Helvetica,"Segoe UI",Arial,freesans,sans-serif;font-size: 16px;line-height: 1.6;ms-text-size-adjust: 100%;overflow: hidden;webkit-text-size-adjust: 100%;word-wrap: break-word;}.markdown-body strong{font-weight: 700;}.markdown-body h1{margin: .67em 0;}.markdown-body img{border: 0;}.markdown-body hr{box-sizing: content-box;moz-box-sizing: content-box;}.markdown-body input{color: inherit;font: 13px/1.4 Helvetica,arial,freesans,clean,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";line-height: normal;margin: 0;}.markdown-body code,.markdown-body pre{font: 12px Consolas,"Liberation Mono",Menlo,Courier,monospace;}.markdown-body html input[disabled]{cursor: default;}.markdown-body input[type=checkbox]{box-sizing: border-box;moz-box-sizing: border-box;padding: 0;}.markdown-body *{box-sizing: border-box;moz-box-sizing: border-box;}.markdown-body a{background: 0 0;color: #4183c4;text-decoration: none;}.markdown-body a:active,.markdown-body a:focus,.markdown-body a:hover{text-decoration: underline;}.markdown-body hr:after{clear: both;}.markdown-body blockquote{margin: 0;}.markdown-body h1,.markdown-body h2{border-bottom: 1px solid #eee;padding-bottom: .3em;}.markdown-body ol ol,.markdown-body ul ol{list-style-type: lower-roman;}.markdown-body ol ol ol,.markdown-body ol ul ol,.markdown-body ul ol ol,.markdown-body ul ul ol{list-style-type: lower-alpha;}.markdown-body dd{margin-left: 0;}.markdown-body pre{word-wrap: normal;}.markdown-body .octicon{display: inline-block;font: normal normal 16px octicons-anchor;line-height: 1;moz-osx-font-smoothing: grayscale;moz-user-select: none;ms-user-select: none;text-decoration: none;user-select: none;webkit-font-smoothing: antialiased;webkit-user-select: none;}.markdown-body .octicon-link:before{content: '\f05c';}.markdown-body>:first-child{margin-top: 0!important;}.markdown-body>:last-child{margin-bottom: 0!important;}.markdown-body .anchor{bottom: 0;display: block;left: 0;margin-left: -30px;padding-left: 30px;padding-right: 6px;position: absolute;top: 0;}.markdown-body h1,.markdown-body h2,.markdown-body h3,.markdown-body h4,.markdown-body h5,.markdown-body h6{font-weight: 700;line-height: 1.4;margin-bottom: 16px;margin-top: 1em;position: relative;}.markdown-body h1 .octicon-link,.markdown-body h2 .octicon-link,.markdown-body h3 .octicon-link,.markdown-body h4 .octicon-link,.markdown-body h5 .octicon-link,.markdown-body h6 .octicon-link{color: #000;display: none;vertical-align: middle;}.markdown-body h1:hover .anchor,.markdown-body h2:hover .anchor,.markdown-body h3:hover .anchor,.markdown-body h4:hover .anchor,.markdown-body h5:hover .anchor,.markdown-body h6:hover .anchor{line-height: 1;margin-left: -30px;padding-left: 8px;text-decoration: none;}.markdown-body h1:hover .anchor .octicon-link,.markdown-body h2:hover .anchor .octicon-link,.markdown-body h3:hover .anchor .octicon-link,.markdown-body h4:hover .anchor .octicon-link,.markdown-body h5:hover .anchor .octicon-link,.markdown-body h6:hover .anchor .octicon-link{display: inline-block;}.markdown-body h1{font-size: 2.25em;line-height: 1.2;}.markdown-body h2{font-size: 1.75em;line-height: 1.225;}.markdown-body h3{font-size: 1.5em;line-height: 1.43;}.markdown-body h4{font-size: 1.25em;}.markdown-body h5{font-size: 1em;}.markdown-body h6{color: #777;font-size: 1em;}.markdown-body blockquote,.markdown-body dl,.markdown-body ol,.markdown-body p,.markdown-body pre,.markdown-body table,.markdown-body ul{margin-bottom: 16px;margin-top: 0;}.markdown-body hr{background: #e7e7e7;border: 0;height: 4px;margin: 16px 0;overflow: hidden;padding: 0;}.markdown-body ol,.markdown-body ul{padding-left: 2em;}.markdown-body ol ol,.markdown-body ol ul,.markdown-body ul ol,.markdown-body ul ul{margin-bottom: 0;margin-top: 0;}.markdown-body li>p{margin-top: 16px;}.markdown-body dl{padding: 0;}.markdown-body dl dt{font-size: 1em;font-style: italic;font-weight: 700;margin-top: 16px;padding: 0;}.markdown-body dl dd{margin-bottom: 16px;padding: 0 16px;}.markdown-body blockquote{border-left: 4px solid #ddd;color: #777;padding: 0 15px;}.markdown-body blockquote>:first-child{margin-top: 0;}.markdown-body blockquote>:last-child{margin-bottom: 0;}.markdown-body table{border-collapse: collapse;border-spacing: 0;display: block;overflow: auto;width: 100%;word-break: keep-all;word-break: normal;}.markdown-body table th{font-weight: 700;}.markdown-body table td,.markdown-body table th{border: 1px solid #ddd;padding: 6px 13px;}.markdown-body table tr{background-color: #fff;border-top: 1px solid #ccc;}.markdown-body table tr:nth-child(2n){background-color: #f8f8f8;}.markdown-body img{box-sizing: border-box;max-width: 100%;moz-box-sizing: border-box;}.markdown-body code{background-color: rgba(0,0,0,.04);border-radius: 3px;font-size: 85%;margin: 0;padding: .2em 0;}.markdown-body code:after,.markdown-body code:before{content: "\00a0";letter-spacing: -.2em;}.markdown-body pre>code{background: 0 0;border: 0;font-size: 100%;margin: 0;padding: 0;white-space: pre;word-break: normal;}.markdown-body .highlight{color: #5e6e5e;margin-bottom: 16px;}.markdown-body .highlight pre,.markdown-body pre{background-color: #fbebd4;border-radius: 3px;font-size: 85%;line-height: 1.45;overflow: auto;padding: 16px;}.markdown-body .highlight pre{margin-bottom: 0;word-break: normal;}.markdown-body pre code{background-color: transparent;border: 0;display: inline;line-height: inherit;margin: 0;max-width: initial;overflow: initial;padding: 0;word-wrap: normal;}.markdown-body pre code:after,.markdown-body pre code:before{content: normal;}.markdown-body .pl-c{color: #379a37;}.markdown-body .pl-c1,.markdown-body .pl-mdh,.markdown-body .pl-mm,.markdown-body .pl-mp,.markdown-body .pl-mr,.markdown-body .pl-s1 .pl-v,.markdown-body .pl-s3,.markdown-body .pl-sc,.markdown-body .pl-sv{color: #0086b3;}.markdown-body .pl-e,.markdown-body .pl-en{color: #40a070;}.markdown-body .pl-s1 .pl-s2,.markdown-body .pl-smi,.markdown-body .pl-smp,.markdown-body .pl-stj,.markdown-body .pl-vo,.markdown-body .pl-vpf{color: #a57a4c;}.markdown-body .pl-ent{color: #63a35c;}.markdown-body .pl-k,.markdown-body .pl-s,.markdown-body .pl-st{color: #ad2bee;}.markdown-body .pl-pds,.markdown-body .pl-s1,.markdown-body .pl-s1 .pl-pse .pl-s2,.markdown-body .pl-sr,.markdown-body .pl-sr .pl-cce,.markdown-body .pl-sr .pl-sra,.markdown-body .pl-sr .pl-sre,.markdown-body .pl-src,.markdown-body .pl-v{color: #df5000;}.markdown-body .pl-id{color: #b52a1d;}.markdown-body .pl-ii{background-color: #b52a1d;color: #f8f8f8;}.markdown-body .pl-sr .pl-cce{color: #63a35c;font-weight: 700;}.markdown-body .pl-ml{color: #693a17;}.markdown-body .pl-mh,.markdown-body .pl-mh .pl-en,.markdown-body .pl-ms{color: #1d3e81;font-weight: 700;}.markdown-body .pl-mq{color: teal;}.markdown-body .pl-mi{color: #a57a4c;font-style: italic;}.markdown-body .pl-mb{color: #a57a4c;font-weight: 700;}.markdown-body .pl-md,.markdown-body .pl-mdhf{background-color: #ffecec;color: #bd2c00;}.markdown-body .pl-mdht,.markdown-body .pl-mi1{background-color: #eaffea;color: #55a532;}.markdown-body .pl-mdr{color: #795da3;font-weight: 700;}.markdown-body .pl-mo{color: #1d3e81;}.markdown-body kbd{background-color: #e7e7e7;background-image: linear-gradient(#fefefe,#e7e7e7);background-image: -webkit-linear-gradient(#fefefe,#e7e7e7);background-repeat: repeat-x;border: 1px solid #cfcfcf;border-radius: 2px;color: #000;display: inline-block;font: 11px Consolas,"Liberation Mono",Menlo,Courier,monospace;line-height: 10px;padding: 3px 5px;}a.source-button,a.toc-button{border-radius: 3px;cursor: pointer;font-size: large;font-weight: 700;}.markdown-body .task-list-item{list-style-type: none;}.markdown-body .task-list-item+.task-list-item{margin-top: 3px;}.markdown-body .task-list-item input{float: left;margin: .3em 0 .25em -1.6em;vertical-align: middle;}.markdown-body :checked+.radio-label{border-color: #4183c4;position: relative;z-index: 1;}a.toc-button:hover{background: #E8E4D9;color: #A88C3F;}a.toc-button{color: #465DA6;padding: .3em .5em .5em;}a.source-button:hover{background: #E8E4D9;color: #A88C3F;}a.source-button{color: #465DA6;}.markdown-body #user-content-note {background-color:#6ab0de;color:white;}.markdown-body #user-content-note p {background-color:#e7f2fa;color:black;padding: 10px;}.markdown-body #user-content-warning {background-color:#f0b37e;color:white;}.markdown-body #user-content-warning p {background-color:#ffedcc;color:black;padding: 10px;}codeblocks[class*=highlight-source-],div[class*=highlight-source-]{font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}div[class*=highlight-source-]{padding:1em;margin:.5em 0;overflow:auto}:not(div)>codeblocks[class*=highlight-source-]{padding:.1em;border-radius:.3em}div.line-numbers,div.line-numbers>codeblocks{position:relative}div.line-numbers{padding-left:3.8em;counter-reset:linenumber}.line-numbers-rows{display:none}.line-numbers .line-numbers-rows{display:block;position:absolute;pointer-events:none;top:0;font-size:100%!;(MISSING)left:-3.8em;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.line-numbers-rows>span{pointer-events:none;display:block;counter-increment:linenumber}.line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right}</style><body><div class="readme"><article class="markdown-body"><h1>File <code>doc.my</code></h1>
<p><div><a id="toc-button" class="toc-button" onclick="toggle_toc()"><span id="btn-text">&#x25BC;</span>&nbsp;Table of Contents</a><div id="table-of-contents" style="display:none;">
<ul>
<li>
<p>Lets</p>
<ul>
<li><a href="#center">CENTER</a></li>
<li><a href="#parse">Parse</a></li>
<li><a href="#size">SIZE</a></li>
</ul>
</li>
<li>
<p>Enums</p>
<ul>
<li><a href="#color">Color</a></li>
<li><a href="#logoption">LogOption</a></li>
</ul>
</li>
<li>
<p>Functions</p>
<ul>
<li><a href="#add">Add</a></li>
<li><a href="#div">Div</a></li>
<li><a href="#mul">Mul</a></li>
<li><a href="#sub">Sub</a></li>
</ul>
</li>
<li>
<p>Classes</p>
<ul>
<li>
<p><a href="#departmentvalidator">DepartmentValidator</a></p>
</li>
<li>
<p><a href="#minmaxvalidator">MinMaxValidator</a></p>
</li>
<li>
<p><a href="#nospacevalidator">NoSpaceValidator</a></p>
</li>
<li>
<p><a href="#person">Person</a></p>
<ul>
<li>
<p>Lets</p>
<ul>
<li><a href="#firstname">firstName</a></li>
<li><a href="#lastname">lastName</a></li>
</ul>
</li>
<li>
<p>Functions</p>
<ul>
<li><a href="#msg">Msg</a></li>
<li><a href="#init">init</a></li>
</ul>
</li>
</ul>
</li>
<li>
<p><a href="#request">Request</a></p>
</li>
<li>
<p><a href="#requesthandler">RequestHandler</a></p>
</li>
<li>
<p><a href="#requestmain">RequestMain</a></p>
</li>
</ul>
</li>
</ul>
</div></br>
<h2>Lets</h2>
<h3 id="center">CENTER</h3>
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift"><span class="pl-k">let</span> CENTER <span class="pl-k">=</span> <span class="pl-c1">15.0</span><span class="line-numbers-rows" style="left: -60px;"><span></span></codeblocks></pre></div>

This is the constant 'CENTER'.
<h3 id="parse">Parse</h3>
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift"><span class="pl-k">let</span> Parse <span class="pl-k">=</span> <span class="pl-c1">fn</span>(lexer) {
	fmt.<span class="pl-c1">Printf</span>(<span class="pl-s"><span class="pl-pds">"</span>This is the parser part!<span class="pl-cce">\n</span><span class="pl-pds">"</span></span>) <span class="pl-c"><span class="pl-c">//</span>just a demo</span>
<span class="pl-c"></span>	fmt.<span class="pl-c1">Printf</span>(<span class="pl-s"><span class="pl-pds">"</span>The parser take a lexer as input, and generate an AST<span class="pl-cce">\n</span><span class="pl-pds">"</span></span>)
}<span class="line-numbers-rows" style="left: -60px;"><span></span><span></span><span></span><span></span></codeblocks></pre></div>

This is a demo parser
<h3 id="size">SIZE</h3>
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift"><span class="pl-k">let</span> SIZE <span class="pl-k">=</span> <span class="pl-c1">10</span><span class="line-numbers-rows" style="left: -60px;"><span></span></codeblocks></pre></div>

This is the constant 'SIZE'.
<h2>Enums</h2>
<h3 id="color">Color</h3>
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift"><span class="pl-k">enum</span> <span class="pl-en">Color</span> {
	RED <span class="pl-k">=</span> <span class="pl-c1">0</span>,
	BLUE <span class="pl-k">=</span> <span class="pl-c1">1</span>,
	YELLOW <span class="pl-k">=</span> <span class="pl-c1">2</span>,
	BLACK <span class="pl-k">=</span> <span class="pl-c1">3</span>,
	WHITE <span class="pl-k">=</span> <span class="pl-c1">4</span>,
	GRAY <span class="pl-k">=</span> <span class="pl-c1">5</span>
};<span class="line-numbers-rows" style="left: -60px;"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></codeblocks></pre></div>

Color enum is the color of the image.
This is just for demo purpose.
<h3 id="logoption">LogOption</h3>
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift"><span class="pl-k">enum</span> <span class="pl-en">LogOption</span> {
	Ldate         <span class="pl-k">=</span> <span class="pl-c1">1</span> <span class="pl-k">&lt;&lt;</span> <span class="pl-c1">0</span>,
	Ltime         <span class="pl-k">=</span> <span class="pl-c1">1</span> <span class="pl-k">&lt;&lt;</span> <span class="pl-c1">1</span>,
	Lmicroseconds <span class="pl-k">=</span> <span class="pl-c1">1</span> <span class="pl-k">&lt;&lt;</span> <span class="pl-c1">2</span>,
	Llongfile     <span class="pl-k">=</span> <span class="pl-c1">1</span> <span class="pl-k">&lt;&lt;</span> <span class="pl-c1">3</span>,
	Lshortfile    <span class="pl-k">=</span> <span class="pl-c1">1</span> <span class="pl-k">&lt;&lt;</span> <span class="pl-c1">4</span>,
	LUTC          <span class="pl-k">=</span> <span class="pl-c1">1</span> <span class="pl-k">&lt;&lt;</span> <span class="pl-c1">5</span>,
	LstdFlags     <span class="pl-k">=</span> <span class="pl-c1">1</span> <span class="pl-k">&lt;&lt;</span> <span class="pl-c1">4</span> <span class="pl-k">|</span> <span class="pl-c1">1</span> <span class="pl-k">&lt;&lt;</span> <span class="pl-c1">5</span>
};<span class="line-numbers-rows" style="left: -60px;"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></codeblocks></pre></div>

LogOption enum is defined for Log options.
<h2>Functions</h2>
<h3 id="add">Add</h3>
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift">fn <span class="pl-c1">Add</span> (x, y) <span class="line-numbers-rows" style="left: -60px;"><span></span></codeblocks></pre></div>

Add returns the addition of its two parameters
<p>This is a example of calling <code>Add</code> with two ints:</p>
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift">sum <span class="pl-k">=</span> <span class="pl-c1">Add</span>(<span class="pl-c1">1</span>, <span class="pl-c1">2</span>) <span class="pl-c"><span class="pl-c">//</span>result is 3</span>
<span class="pl-c"></span>sum <span class="pl-k">=</span> <span class="pl-c1">Add</span>(<span class="pl-c1">4</span>, <span class="pl-c1">5</span>) <span class="pl-c"><span class="pl-c">//</span>result is 9</span>
<span class="pl-c"></span>sum <span class="pl-k">=</span> <span class="pl-c1">Add</span>(<span class="pl-c1">-1</span>, <span class="pl-c1">2</span>) <span class="pl-c"><span class="pl-c">//</span>result is 1</span><span class="line-numbers-rows" style="left: -60px;"><span></span><span></span><span></span></codeblocks></pre></div>

<p>This is a example of calling <code>Add</code> with two strings:</p>
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift">sum <span class="pl-k">=</span> <span class="pl-c1">Add</span>(<span class="pl-s"><span class="pl-pds">"</span>Hello <span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>world<span class="pl-pds">"</span></span>) <span class="pl-c"><span class="pl-c">//</span>result is "Hello world"</span>
<span class="pl-c"></span>sum <span class="pl-k">=</span> <span class="pl-c1">Add</span>(<span class="pl-s"><span class="pl-pds">"</span>Welcome <span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>world<span class="pl-pds">"</span></span>) <span class="pl-c"><span class="pl-c">//</span>result is "Welcome world"</span>
<span class="pl-c"></span>sum <span class="pl-k">=</span> <span class="pl-c1">Add</span>(<span class="pl-s"><span class="pl-pds">"</span>Hi <span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>world<span class="pl-pds">"</span></span>) <span class="pl-c"><span class="pl-c">//</span>result is "Hi world"</span><span class="line-numbers-rows" style="left: -60px;"><span></span><span></span><span></span></codeblocks></pre></div>

<h4>Parameters</h4>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>x</td>
<td><code>int</code></td>
<td>this is the first parameter</td>
</tr>
<tr>
<td>y</td>
<td><code>int</code></td>
<td>this is the second parameter</td>
</tr></tbody></table>
<h4>Returns</h4>
<ul>
<li>
<p><code>int</code> the addition of it's two parameters if both parameters are ints.</p>
</li>
<li>
<p><code>string</code> the string concatenation of it's two parameters if both parameters are strings</p>
</li>
</ul>
<p><div><a id="source-button" class="source-button" onclick="toggle_source('Add')"><span id="btn-text-Add">&#x25BC;</span>&nbsp;Show source</a><div id="showsource-Add" style="display:none;">
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift">fn <span class="pl-c1">Add</span>(x,y) {
	<span class="pl-k">return</span> x <span class="pl-k">+</span> y
}<span class="line-numbers-rows" style="left: -60px;"><span></span><span></span><span></span></codeblocks></pre></div>

</div></br>
<h3 id="div">Div</h3>
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift">fn <span class="pl-c1">Div</span> (x, y) <span class="line-numbers-rows" style="left: -60px;"><span></span></codeblocks></pre></div>

Div returns the division of its two parameters
<p><div><a id="source-button" class="source-button" onclick="toggle_source('Div')"><span id="btn-text-Div">&#x25BC;</span>&nbsp;Show source</a><div id="showsource-Div" style="display:none;">
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift">fn <span class="pl-c1">Div</span>(x,y) {
	<span class="pl-k">return</span> x <span class="pl-k">/</span> y
}<span class="line-numbers-rows" style="left: -60px;"><span></span><span></span><span></span></codeblocks></pre></div>

</div></br>
<h3 id="mul">Mul</h3>
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift">fn <span class="pl-c1">Mul</span> (x, y) <span class="line-numbers-rows" style="left: -60px;"><span></span></codeblocks></pre></div>

Mul returns the multiply of its two parameters
<p><div><a id="source-button" class="source-button" onclick="toggle_source('Mul')"><span id="btn-text-Mul">&#x25BC;</span>&nbsp;Show source</a><div id="showsource-Mul" style="display:none;">
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift">fn <span class="pl-c1">Mul</span>(x,y) {
	<span class="pl-k">return</span> x <span class="pl-k">*</span> y
}<span class="line-numbers-rows" style="left: -60px;"><span></span><span></span><span></span></codeblocks></pre></div>

</div></br>
<h3 id="sub">Sub</h3>
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift">fn <span class="pl-c1">Sub</span> (x, y) <span class="line-numbers-rows" style="left: -60px;"><span></span></codeblocks></pre></div>

Sub returns the subtraction of its two parameters
<h4>Parameters</h4>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>x</td>
<td><code>int</code></td>
<td>this is the first parameter</td>
</tr>
<tr>
<td>y</td>
<td><code>int</code></td>
<td>this is the second parameter</td>
</tr></tbody></table>
<h4>Returns</h4>
<ul>
<li><code>int</code> the subtraction of it's two parameters</li>
</ul>
<p><div><a id="source-button" class="source-button" onclick="toggle_source('Sub')"><span id="btn-text-Sub">&#x25BC;</span>&nbsp;Show source</a><div id="showsource-Sub" style="display:none;">
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift">fn <span class="pl-c1">Sub</span>(x,y) {
	<span class="pl-k">return</span> x <span class="pl-k">-</span> y
}<span class="line-numbers-rows" style="left: -60px;"><span></span><span></span><span></span></codeblocks></pre></div>

</div></br>
<h2>Classes</h2>
<h3 id="departmentvalidator">DepartmentValidator</h3>
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift"><span class="pl-k">class</span> <span class="pl-k">@DepartmentValidator</span>{ <span class="pl-k">...</span> }<span class="line-numbers-rows" style="left: -60px;"><span></span></codeblocks></pre></div>

DepartmentValidator annotation class.
It is used for checking a list of department.
<p><div><a id="source-button" class="source-button" onclick="toggle_source('DepartmentValidator')"><span id="btn-text-DepartmentValidator">&#x25BC;</span>&nbsp;Show source</a><div id="showsource-DepartmentValidator" style="display:none;">
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift"><span class="pl-k">class</span> <span class="pl-k">@DepartmentValidator</span> {
  property Department
}<span class="line-numbers-rows" style="left: -60px;"><span></span><span></span><span></span></codeblocks></pre></div>

</div></br>
<h3 id="minmaxvalidator">MinMaxValidator</h3>
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift"><span class="pl-k">class</span> <span class="pl-k">@MinMaxValidator</span>{ <span class="pl-k">...</span> }<span class="line-numbers-rows" style="left: -60px;"><span></span></codeblocks></pre></div>

MinMaxValidator annotation class
It is used for checking min and max length
The max length has a default value of 10
<p><div><a id="source-button" class="source-button" onclick="toggle_source('MinMaxValidator')"><span id="btn-text-MinMaxValidator">&#x25BC;</span>&nbsp;Show source</a><div id="showsource-MinMaxValidator" style="display:none;">
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift"><span class="pl-k">class</span> <span class="pl-k">@MinMaxValidator</span> {
  property MinLength
  property MaxLength <span class="pl-k">default</span> <span class="pl-c1">10</span>
}<span class="line-numbers-rows" style="left: -60px;"><span></span><span></span><span></span><span></span></codeblocks></pre></div>

</div></br>
<h3 id="nospacevalidator">NoSpaceValidator</h3>
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift"><span class="pl-k">class</span> <span class="pl-k">@NoSpaceValidator</span>{ <span class="pl-k">...</span> }<span class="line-numbers-rows" style="left: -60px;"><span></span></codeblocks></pre></div>

NoSpaceValidator annotation class(it's a marker annotation).
It is used for checking spaces.
<p><div><a id="source-button" class="source-button" onclick="toggle_source('NoSpaceValidator')"><span id="btn-text-NoSpaceValidator">&#x25BC;</span>&nbsp;Show source</a><div id="showsource-NoSpaceValidator" style="display:none;">
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift"><span class="pl-k">class</span> <span class="pl-k">@NoSpaceValidator</span> {}<span class="line-numbers-rows" style="left: -60px;"><span></span></codeblocks></pre></div>

</div></br>
<h3 id="person">Person</h3>
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift"><span class="pl-k">class</span> <span class="pl-en">Person</span>{ <span class="pl-k">...</span> }<span class="line-numbers-rows" style="left: -60px;"><span></span></codeblocks></pre></div>

 A Persion class which has three private variable:
* firstName
* lastName
* nickName
<p>and two methods :'init' and 'Msg'.</p>
<h4>Lets</h4>
<h5 id="firstname">firstName</h5>
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift"><span class="pl-k">let</span> firstName; <span class="line-numbers-rows" style="left: -60px;"><span></span></codeblocks></pre></div>

this is the firstname
<h5 id="lastname">lastName</h5>
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift"><span class="pl-k">let</span> lastName; <span class="line-numbers-rows" style="left: -60px;"><span></span></codeblocks></pre></div>

this is the last name
<h4>Functions</h4>
<h5 id="msg">Msg</h5>
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift">fn <span class="pl-c1">Msg</span> (extra1, extra2, args) <span class="line-numbers-rows" style="left: -60px;"><span></span></codeblocks></pre></div>

Method 'Msg' demonstrate function default values and variable arguements
<h4>Parameters</h4>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>extra1</td>
<td><code>string</code></td>
<td>this is extra1</td>
</tr>
<tr>
<td>extra2</td>
<td><code>string</code></td>
<td>this is extra2, it has default value "extra2"</td>
</tr>
<tr>
<td>args</td>
<td><code>array</code></td>
<td>this is args</td>
</tr></tbody></table>
<h5 id="init">init</h5>
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift">fn <span class="pl-k">init</span> (firstname, lastname, nickname) <span class="line-numbers-rows" style="left: -60px;"><span></span></codeblocks></pre></div>

This is the constructor of the Person class.
<p><div><a id="source-button" class="source-button" onclick="toggle_source('Person')"><span id="btn-text-Person">&#x25BC;</span>&nbsp;Show source</a><div id="showsource-Person" style="display:none;">
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift"><span class="pl-k">class</span> <span class="pl-en">Person</span> {
	<span class="pl-c"><span class="pl-c">//</span>this is the firstname</span>
<span class="pl-c"></span>	<span class="pl-k">let</span> firstName;
	<span class="pl-c"><span class="pl-c">//</span>this is the last name</span>
<span class="pl-c"></span>	<span class="pl-k">let</span> lastName;
	<span class="pl-k">let</span> nickName; <span class="pl-c"><span class="pl-c">//</span> this is the nick name</span>
<span class="pl-c"></span>
	<span class="pl-c"><span class="pl-c">//</span>This is the constructor of the Person class.</span>
<span class="pl-c"></span>	fn <span class="pl-k">init</span>(firstname, lastname="huang", nickname="mike") {
		this.<span class="pl-smi">firstName</span> <span class="pl-k">=</span> firstname
		this.<span class="pl-smi">lastName</span> <span class="pl-k">=</span> lastname
		this.<span class="pl-smi">nickName</span> <span class="pl-k">=</span> nickname
	}

	<span class="pl-c"><span class="pl-c">/*</span> Method 'Msg' demonstrate function default values and variable arguements</span>
<span class="pl-c">	 * @param {string} extra1  this is extra1</span>
<span class="pl-c">	 * @param {string} extra2  this is extra2, it has default value "extra2"</span>
<span class="pl-c">	 * @param {array}  args this is args</span>
<span class="pl-c">	<span class="pl-c">*/</span></span>
	fn <span class="pl-c1">Msg</span>(extra1, extra2<span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">"</span>extra2<span class="pl-pds">"</span></span>, args<span class="pl-k">...</span>) {
		<span class="pl-c1">printf</span>(<span class="pl-s"><span class="pl-pds">"</span>firstName=%s, lastName=%s, nickName=%s<span class="pl-cce">\n</span><span class="pl-pds">"</span></span>, firstName, lastName, nickName)
		<span class="pl-c1">printf</span>(<span class="pl-s"><span class="pl-pds">"</span>extra1=%s, extra2=%s<span class="pl-cce">\n</span><span class="pl-pds">"</span></span>, extra1, extra2)
		<span class="pl-k">for</span> i <span class="pl-k">in</span> args {
			<span class="pl-c1">printf</span>(<span class="pl-s"><span class="pl-pds">"</span>i=%v<span class="pl-cce">\n</span><span class="pl-pds">"</span></span>, i)
		}
	}
}<span class="line-numbers-rows" style="left: -60px;"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></codeblocks></pre></div>

</div></br>
<h3 id="request">Request</h3>
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift"><span class="pl-k">class</span> <span class="pl-en">Request</span>{ <span class="pl-k">...</span> }<span class="line-numbers-rows" style="left: -60px;"><span></span></codeblocks></pre></div>

Request class represent a user made request.
<p><div><a id="source-button" class="source-button" onclick="toggle_source('Request')"><span id="btn-text-Request">&#x25BC;</span>&nbsp;Show source</a><div id="showsource-Request" style="display:none;">
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift"><span class="pl-k">class</span> <span class="pl-en">Request</span> {
  <span class="pl-c"><span class="pl-c">/*</span> FirstName property, it's value's length should be between 1(minlenght) and 10(maxlength). <span class="pl-c">*/</span></span>
  <span class="pl-k">@MinMaxValidator</span>(MinLength<span class="pl-k">=</span><span class="pl-c1">1</span>)
  property FirstName;

  <span class="pl-c"><span class="pl-c">//</span>LastName property, it's value should contain no space.</span>
<span class="pl-c"></span>  <span class="pl-k">@NoSpaceValidator</span>
  property LastName;

  <span class="pl-c"><span class="pl-c">//</span>Dept property, it's value should be in a list ["Department of Education", "Department of Labors"].</span>
<span class="pl-c"></span>  <span class="pl-k">@DepartmentValidator</span>(Department<span class="pl-k">=</span>[<span class="pl-s"><span class="pl-pds">"</span>Department of Education<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>Department of Labors<span class="pl-pds">"</span></span>])
  property Dept;
}<span class="line-numbers-rows" style="left: -60px;"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></codeblocks></pre></div>

</div></br>
<h3 id="requesthandler">RequestHandler</h3>
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift"><span class="pl-k">class</span> <span class="pl-en">RequestHandler</span>{ <span class="pl-k">...</span> }<span class="line-numbers-rows" style="left: -60px;"><span></span></codeblocks></pre></div>

RequestHandler class is responsible for processing the annotation.
<p><div><a id="source-button" class="source-button" onclick="toggle_source('RequestHandler')"><span id="btn-text-RequestHandler">&#x25BC;</span>&nbsp;Show source</a><div id="showsource-RequestHandler" style="display:none;">
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift"><span class="pl-k">class</span> <span class="pl-en">RequestHandler</span> {
  <span class="pl-c"><span class="pl-c">//</span>handle is the real logic of processing the annotations.</span>
<span class="pl-c"></span>  <span class="pl-k">static</span> fn <span class="pl-c1">handle</span>(o) {
    props <span class="pl-k">=</span> o.<span class="pl-c1">getProperties</span>()
    <span class="pl-k">for</span> p <span class="pl-k">in</span> props {
      annos <span class="pl-k">=</span> p.<span class="pl-c1">getAnnotations</span>()
      <span class="pl-k">for</span> anno <span class="pl-k">in</span> annos {
        <span class="pl-k">if</span> anno.<span class="pl-c1">instanceOf</span>(MinMaxValidator) {
          <span class="pl-c"><span class="pl-c">//</span>p.value is the property real value.</span>
<span class="pl-c"></span>          <span class="pl-k">if</span> <span class="pl-c1">len</span>(p.<span class="pl-c1">value</span>) <span class="pl-k">&gt;</span> anno.<span class="pl-smi">MaxLength</span> <span class="pl-k">||</span> <span class="pl-c1">len</span>(p.<span class="pl-c1">value</span>) <span class="pl-k">&lt;</span> anno.<span class="pl-smi">MinLength</span> {
            <span class="pl-c1">printf</span>(<span class="pl-s"><span class="pl-pds">"</span>Property '%s' is not valid!<span class="pl-cce">\n</span><span class="pl-pds">"</span></span>, p.<span class="pl-smi">name</span>)
          }
        } elseif anno.<span class="pl-c1">instanceOf</span>(NoSpaceValidator) {
          <span class="pl-k">for</span> c <span class="pl-k">in</span> p.<span class="pl-c1">value</span> {
            <span class="pl-k">if</span> c <span class="pl-k">==</span> <span class="pl-s"><span class="pl-pds">"</span> <span class="pl-pds">"</span></span> <span class="pl-k">||</span> c <span class="pl-k">==</span> <span class="pl-s"><span class="pl-pds">"</span><span class="pl-cce">\t</span><span class="pl-pds">"</span></span> {
              <span class="pl-c1">printf</span>(<span class="pl-s"><span class="pl-pds">"</span>Property '%s' is not valid!<span class="pl-cce">\n</span><span class="pl-pds">"</span></span>, p.<span class="pl-smi">name</span>)
              <span class="pl-k">break</span>
            }
          }
        } elseif anno.<span class="pl-c1">instanceOf</span>(DepartmentValidator) {
          found <span class="pl-k">=</span> <span class="pl-c1">false</span>
          <span class="pl-k">for</span> d <span class="pl-k">in</span> anno.<span class="pl-smi">Department</span> {
            <span class="pl-k">if</span> p.<span class="pl-c1">value</span> <span class="pl-k">==</span> d {
              found <span class="pl-k">=</span> <span class="pl-c1">true</span>
            }
          }
          <span class="pl-k">if</span> <span class="pl-k">!</span>found {
            <span class="pl-c1">printf</span>(<span class="pl-s"><span class="pl-pds">"</span>Property '%s' is not valid!<span class="pl-cce">\n</span><span class="pl-pds">"</span></span>, p.<span class="pl-smi">name</span>)
          }
        }
      }
    }
  }
}<span class="line-numbers-rows" style="left: -60px;"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></codeblocks></pre></div>

</div></br>
<h3 id="requestmain">RequestMain</h3>
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift"><span class="pl-k">class</span> <span class="pl-en">RequestMain</span>{ <span class="pl-k">...</span> }<span class="line-numbers-rows" style="left: -60px;"><span></span></codeblocks></pre></div>

RequestMain class. It is the user/client code.
<div id="user-content-note"> <g-emoji class="g-emoji" alias="bulb" fallback-src="https://assets-cdn.github.com/images/icons/emoji/unicode/1f4a1.png">💡</g-emoji> Note<p>This is note one.<br>
This is note two.<br>
This is note three.<br>
</p></div>
<div id="user-content-warning"> <g-emoji class="g-emoji" alias="warning" fallback-src="https://assets-cdn.github.com/images/icons/emoji/unicode/26a0.png">⚠️</g-emoji> Warning<p>This is warning one.<br>
This is warning two.<br>
This is warning three.<br>
</p></div>
<p><div><a id="source-button" class="source-button" onclick="toggle_source('RequestMain')"><span id="btn-text-RequestMain">&#x25BC;</span>&nbsp;Show source</a><div id="showsource-RequestMain" style="display:none;">
<div class="highlight highlight-source-swift line-numbers" style="background:#fbebd4"><codeblocks class="highlight-source-swift"><span class="pl-k">class</span> <span class="pl-en">RequestMain</span> {
  <span class="pl-k">static</span> fn <span class="pl-c1">main</span>() {
    request <span class="pl-k">=</span> new <span class="pl-c1">Request</span>()
    request.<span class="pl-smi">FirstName</span> <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">"</span>Haifeng123456789<span class="pl-pds">"</span></span>
    request.<span class="pl-smi">LastName</span> <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">"</span>Huang     <span class="pl-pds">"</span></span>
    request.<span class="pl-smi">Dept</span> <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">"</span>Department of Labors<span class="pl-pds">"</span></span>
    RequestHandler.<span class="pl-c1">handle</span>(request)
  }
}<span class="line-numbers-rows" style="left: -60px;"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></codeblocks></pre></div>

</div></br>
<hr>
<p><em>Last updated 2018-03-08</em></p></article></div></body>
